package com.xiangyueEducation.uploaderCloud.controller;

import com.xiangyueEducation.uploaderCloud.pojo.entity.User;
import com.xiangyueEducation.uploaderCloud.service.InfoService;
import com.xiangyueEducation.uploaderCloud.utils.JwtHelper;
import com.xiangyueEducation.uploaderCloud.utils.Result;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@CrossOrigin
@RequestMapping("info")
public class InfoController {

    @Autowired
    JwtHelper jwtHelper;
    @Autowired
    InfoService infoService;

    @GetMapping("roleId")
    public Result<?> getRoleId(@RequestHeader String token){
        Long userId = jwtHelper.getUserId(token);
        return infoService.getRoleId(userId);
    }



    //学生自己的信息
    @GetMapping("stu/main")
    public Result<?> getStuMainInfo(@RequestHeader String token){
        Long userId = jwtHelper.getUserId(token);
        return infoService.getStuMainInfo(userId);
    }

    @GetMapping("stu/all")
    public Result<?> getStuAllMainInfo(){
        return infoService.getStuAllMainInfo();
    }

    @PostMapping("/stu/update")
    public Result<?> updateStuInfo(@RequestBody User user){
        System.out.println("user = " + user);
        return infoService.updateStuInfo(user);
    }
//    @PostMapping("/stu")
//    public Result<?> addStuInfo(@RequestBody User user){
//        return infoService.addStuInfo(user);
//    }





}
